package com.s2u2m.training.ex_programmer.single_responsibility.good;

import com.s2u2m.training.ex_programmer.single_responsibility.Item;

import java.util.List;
import java.util.stream.Collectors;

public class ShoppingCartPrinter {
    public String print(ShoppingCart cart) {
        List<Item> items = cart.getItems();
        String list = items.stream()
                .map(Item::toString)
                .collect(Collectors.joining("\n"));
        String total = "Total: " + cart.getTotalPrice();
        return String.join("\n", list, total);
    }
}
